<%@ page language="java" pageEncoding="UTF-8"%>
<!--  header -->
<%@ include file="../layouts/header.jsp"%>

<!--  body -->
<div class="Main">
	<div class="Main_fix">


		<%@ include file="../layouts/left.jsp"%>

		<!-- main body -->
		<script type="text/javascript">
			function update(){
				var updateForm = document.getElementById('updateForm');				
				updateForm.submit();
			}
		</script>
		<form action="<j:href controller="${model.lowerCaseFirst}" action="update"/>" method="post" id="updateForm">
			<div class="Main_body" id="Main_body">
				<div class="Main_locationBar">
					<div class="Main_locationBar_head"></div>
					<div class="Main_locationBar_body">
						<span id="CurrentPosition"><fmt:message key="project.name"/> > ${model}</span>
					</div>
					<div class="Main_locationBar_foot"></div>
				</div>


				<div class="Main_bodyAddBar">
					<div class="Main_bodyAddBar_body">
					<div class="Main_hintBar">
						<div class="Main_hintBar_head">
					
						</div>
						<div class="Main_hintBar_body">
								<p>
									<fmt:message key="form.edit.message"/>
								</p>
						</div>
						<div class="Main_hintBar_foot"></div>
					</div>
					<c:if test="${sy}flash['message']!=null}">
					<span>
						${sy}flash['message']}
					</span>
					</c:if>
					
					<table border="0" cellspacing="1" cellpadding="0" class="addTable">
					<#list items as item>
					<tr>
						<#list item as v>
						<td class="title">
						<#if v?exists>
							 ${v}:	
						</#if>		
						</td>
						<td class="content">
						      <#if v?exists>							
							  <#if   v.propertyType=="column">
							  <input type="text" name="${v.lowerCaseFirst}" value="${sy}${model.lowerCaseFirst}.${v.lowerCaseFirst}}"/>	
							  <c:if test="${sy}${model.lowerCaseFirst}.errorMessages['${v.lowerCaseFirst}']!=null}">
							 	 <span>${sy}${model.lowerCaseFirst}.errorMessages['${v.lowerCaseFirst}']} </span>
							  </c:if>	
							  </#if>
							  <#if  v.propertyType=="many_to_one">
							  <j:model model="${v.propertyClass.name}" method="list" var="${v.lowerCaseFirst}List"/>
							  <select name="${v.lowerCaseFirst}.id">
							     <c:forEach var="${v.lowerCaseFirst}" items="${sy}${v.lowerCaseFirst}List}">
								   <option value="${sy}${v.lowerCaseFirst}.id}" 
								     <c:if test="${sy}${v.lowerCaseFirst}.id==${model.lowerCaseFirst}.${v.lowerCaseFirst}.id}">
							 	 		selected
							  		 </c:if>	
								   >
								   ${sy}${v.lowerCaseFirst}}
								   </option>
								   </c:forEach>
							  </select>
							  </#if>
							  </#if>											
						</td>
						</#list>
					</tr>
					</#list>
					<tr>
						<td class="title">
							 Updated At						
						</td>
						<td class="content">
							 ${sy}${model.lowerCaseFirst}.updatedAt}						
						</td>
						<td class="title">
							Created At
						</td>
						<td class="content">
							${sy}${model.lowerCaseFirst}.createdAt}
						</td>
					</tr>
					
				   </table>
				   
				   
			  		</div>
				</div>

				<div class="Main_buttonGroupBar_body">
					<input type="hidden" name="id" value="${sy}${model.lowerCaseFirst}.id}" />
          			<input type="button" class="button" value="<fmt:message key="form.button.update"/>" onclick="update()"/>
          			<input type="button" class="button" value="<fmt:message key="form.button.concel"/>" onclick="window.location = '<j:href controller="${model.lowerCaseFirst}" action="show" oid="${sy}${model.lowerCaseFirst}.id}"/>'"/> 
          			<input type="button" class="button" value="<fmt:message key="form.button.list"/>" onclick="window.location = '<j:href controller="${model.lowerCaseFirst}" action="index"/>'"/>
        		</div>
			</div>
		</form>
	</div>
	<!--  footer -->
	<%@ include file="../layouts/footer.jsp"%>